package com.le.sarrs.web.event;

import com.google.common.collect.Maps;
import reactor.rx.Promise;

import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.Map;

/**
 * @param <T>
 * @author yanghg
 */
public class TranEvent<T> implements Serializable {

    private static final long serialVersionUID = -225796595506339507L;
    private Promise<T> promise;
    @SuppressWarnings("unused")
    private String jspViewName;
    // 当前用户
    @SuppressWarnings("unused")
//    private User user;
    private Map<String, Object> parameters = Maps.newHashMap();
    private Map<String, Object> results = Maps.newHashMap();
    private HttpServletRequest request;

    public void setParam(String key, Object value) {
        this.parameters.put(key, value);
    }

    public Object getParam(String key) {
        return this.parameters.get(key);
    }

    public Map<String, Object> getAllParam() {
        return this.parameters;
    }

    public Object getResult(String key) {
        return this.results.get(key);
    }

    public void setResult(String key, Object value) {
        this.results.put(key, value);
    }

    public void removeResult(String key) {
        this.results.remove(key);
    }

    public Map<String, Object> getAllResults() {
        return this.results;
    }

    public HttpServletRequest getRequest() {
        return request;
    }

    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }

    public Promise<T> getPromise() {
        return promise;
    }

    public void setPromise(Promise<T> promise) {
        this.promise = promise;
    }

}
